﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using APPLICATION.Dict.City;
using APPLICATION.Dict.Clients;
using APPLICATION.Dict.Contracts;
using APPLICATION.Dict.dtAny;
using APPLICATION.Dict.EBK;
using APPLICATION.Dict.Post;

using APPLICATION.UserManager;
namespace APPLICATION
{
    public partial class MainFrame : Form
    {
        public MainFrame()
        {
            InitializeComponent();
        }

        private void navBarItem1_ItemChanged(object sender, EventArgs e)
        {


        }

        private void dictPosts_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Dict.Post.FrmPost frmPosts = new FrmPost();
            MDI_ShowForm_in_Tab(frmPosts);
        }

        private void dictDepartments_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            APPLICATION.Departments.Form1 frmDeps = new APPLICATION.Departments.Form1();
            MDI_ShowForm_in_Tab(frmDeps);
        }

      
        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.TopMost = true;
            this.IsMdiContainer = true;
            
                Dict.City.FrmCity frmCity = new FrmCity();
                Dict.City.FrmCity frm = new Dict.City.FrmCity();
                frm.MdiParent = this;
                frm.Show();
                //MDI_ShowForm_in_Tab(frmCity);
            
            
        }

        private void dictContracts_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Dict.Contracts.frmContracts frmContracts = new frmContracts();
            MDI_ShowForm_in_Tab(frmContracts);
        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        private void userManager_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            //FrmUsers frmGridUser = new FrmUsers();
            //MDI_ShowForm_in_Tab(frmGridUser);
            
        }

        private void dictEbk_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Dict.EBK.frmEBK frm = new frmEBK();
            MDI_ShowForm_in_Tab(frm);
        }

        private void dictPaymentTypes_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            frmAny frmPaymentType = new frmAny();
            frmPaymentType.managerID = 1;
            frmPaymentType.Dcode = 2;
            frmPaymentType.dictName = "Справочник  Форма Оплати";
            frmPaymentType.Text = "Справочник  Форма Оплати";
            frmPaymentType.Show();
        }

     
      private void dictOperationTypes_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
      {
          frmAny frmPaymentType = new frmAny();
          frmPaymentType.managerID = 0;
          frmPaymentType.Dcode = 5;
          frmPaymentType.dictName = "Справочник  род операции";
          frmPaymentType.Text = "Справочник  род операции";
          frmPaymentType.Show();
      }



      private void dictFinancSourses_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
      {
          //Справочник:  Род операции
          frmAny frmPaymentType = new frmAny();
          frmPaymentType.managerID = 4;
          frmPaymentType.Dcode = 1;
          frmPaymentType.dictName = "Справочник:  источники финансирования";
          frmPaymentType.Text = "Справочник:  источники финансирования";
          frmPaymentType.Show();
      }


      internal void MDI_ShowForm_in_Tab(Form form) // es ubralod etods davarkvi
      {
          Cursor.Current = Cursors.WaitCursor;
          Application.DoEvents();

          foreach (Form forma in this.MdiParent.MdiChildren)
          {
              if (forma.Name.Equals(form.Name))
              {
                  forma.Activate();
                  return;

              }
          }

          form.MdiParent = this.MdiParent;
          form.Show();

          Cursor.Current = Cursors.Default;

      }

      private void tbcMain_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
      {
         
             
      }

      private void dictClients_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
      {
          Dict.Clients.Contracts ctr = new Contracts();
          //ctr.ShowDialog();
          MDI_ShowForm_in_Tab(ctr);
      }

      private void MainFrame_Load(object sender, EventArgs e)
      {
          FrmMain FrmMain1 = new FrmMain();
          FrmMain1.ShowDialog();
      }

    }
}
